
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>4.3 Phoenix 创建索引 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    第 1 章 Phoenix 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第 2 章 Phoenix 快速入门
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/21-an-zhuang-bu-shu.html">
            
                <a href="../chapter1/21-an-zhuang-bu-shu.html">
            
                    
                    2.1 安装部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/22-phoenix-biao-cao-zuo.html">
            
                <a href="../chapter1/22-phoenix-biao-cao-zuo.html">
            
                    
                    2.2 Phoenix 表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/23-phoenix-biao-ying-she.html">
            
                <a href="../chapter1/23-phoenix-biao-ying-she.html">
            
                    
                    2.3 Phoenix 表映射
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                <a href="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                    
                    第 3 章 Phoenix 图形化工具: Squirrel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                    
                    第 4 章 Phoenix 创建 HBase 二级索引
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="41-hbase-de-er-ji-suo-yin.html">
            
                <a href="41-hbase-de-er-ji-suo-yin.html">
            
                    
                    4.1 HBase 的二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                <a href="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                    
                    4.2 配置 HBase 支持 Phoenix 创建二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.3" data-path="43-chuang-jian-suo-yin.html">
            
                <a href="43-chuang-jian-suo-yin.html">
            
                    
                    4.3 Phoenix 创建索引
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >4.3 Phoenix 创建索引</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="43-phoenix-&#x521B;&#x5EFA;&#x7D22;&#x5F15;">4.3 Phoenix &#x521B;&#x5EFA;&#x7D22;&#x5F15;</h1>
<h2 id="431-phoenix-&#x7D22;&#x5F15;&#x5206;&#x7C7B;">4.3.1 Phoenix &#x7D22;&#x5F15;&#x5206;&#x7C7B;</h2>
<p>Phoenix &#x7D22;&#x5F15;&#x5206;&#x5168;&#x5C40;&#x7D22;&#x5F15;&#x548C;&#x5C40;&#x90E8;&#x7D22;&#x5F15;</p>
<h3 id="&#x5168;&#x5C40;&#x7D22;&#x5F15;">&#x5168;&#x5C40;&#x7D22;&#x5F15;</h3>
<p>global index &#x662F;&#x9ED8;&#x8BA4;&#x7684;&#x7D22;&#x5F15;&#x683C;&#x5F0F;&#x3002;</p>
<p>&#x9002;&#x7528;&#x4E8E;&#x591A;&#x8BFB;&#x5C11;&#x5199;&#x7684;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x3002;&#x5199;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x6D88;&#x8017;&#x5927;&#x91CF;&#x5F00;&#x9500;&#xFF0C;&#x56E0;&#x4E3A;&#x7D22;&#x5F15;&#x8868;&#x4E5F;&#x8981;&#x66F4;&#x65B0;&#xFF0C;&#x800C;&#x7D22;&#x5F15;&#x8868;&#x662F;&#x5206;&#x5E03;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x8282;&#x70B9;&#x4E0A;&#x7684;&#xFF0C;&#x8DE8;&#x8282;&#x70B9;&#x7684;&#x6570;&#x636E;&#x4F20;&#x8F93;&#x5E26;&#x6765;&#x4E86;&#x8F83;&#x5927;&#x7684;&#x6027;&#x80FD;&#x6D88;&#x8017;&#x3002;</p>
<p>&#x5728;&#x8BFB;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019; Phoenix &#x4F1A;&#x9009;&#x62E9;&#x7D22;&#x5F15;&#x8868;&#x6765;&#x964D;&#x4F4E;&#x67E5;&#x8BE2;&#x6D88;&#x8017;&#x7684;&#x65F6;&#x95F4;&#x3002;</p>
<p>&#x5982;&#x679C;&#x60F3;&#x67E5;&#x8BE2;&#x7684;&#x5B57;&#x6BB5;&#x4E0D;&#x662F;&#x7D22;&#x5F15;&#x5B57;&#x6BB5;&#x7684;&#x8BDD;&#x7D22;&#x5F15;&#x8868;&#x4E0D;&#x4F1A;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x4E0D;&#x4F1A;&#x5E26;&#x6765;&#x67E5;&#x8BE2;&#x901F;&#x5EA6;&#x7684;&#x63D0;&#x5347;&#x3002;</p>
<blockquote>
<p>&#x521B;&#x5EFA;&#x5168;&#x5C40;&#x7D22;&#x5F15;&#x7684;&#x65B9;&#x6CD5;: </p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">INDEX</span> my_index <span class="hljs-keyword">ON</span> my_table (my_col)
</code></pre>
<h3 id="&#x5C40;&#x90E8;&#x7D22;&#x5F15;">&#x5C40;&#x90E8;&#x7D22;&#x5F15;</h3>
<p>local index &#x9002;&#x7528;&#x4E8E;&#x5199;&#x64CD;&#x4F5C;&#x9891;&#x7E41;&#x7684;&#x573A;&#x666F;&#x3002;&#x7D22;&#x5F15;&#x6570;&#x636E;&#x548C;&#x6570;&#x636E;&#x8868;&#x7684;&#x6570;&#x636E;&#x662F;&#x5B58;&#x653E;&#x5728;&#x76F8;&#x540C;&#x7684;&#x670D;&#x52A1;&#x5668;&#x4E2D;&#x7684;&#xFF0C;&#x907F;&#x514D;&#x4E86;&#x5728;&#x5199;&#x64CD;&#x4F5C;&#x7684;&#x65F6;&#x5019;&#x5F80;&#x4E0D;&#x540C;&#x670D;&#x52A1;&#x5668;&#x7684;&#x7D22;&#x5F15;&#x8868;&#x4E2D;&#x5199;&#x7D22;&#x5F15;&#x5E26;&#x6765;&#x7684;&#x989D;&#x5916;&#x5F00;&#x9500;&#x3002;</p>
<p>&#x67E5;&#x8BE2;&#x7684;&#x5B57;&#x6BB5;&#x4E0D;&#x662F;&#x7D22;&#x5F15;&#x5B57;&#x6BB5;&#x7D22;&#x5F15;&#x8868;&#x4E5F;&#x4F1A;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x8FD9;&#x4F1A;&#x5E26;&#x6765;&#x67E5;&#x8BE2;&#x901F;&#x5EA6;&#x7684;&#x63D0;&#x5347;&#x3002;</p>
<blockquote>
<p>&#x521B;&#x5EFA;&#x5C40;&#x90E8;&#x7D22;&#x5F15;&#x7684;&#x65B9;&#x6CD5;(&#x76F8;&#x6BD4;&#x5168;&#x5C40;&#x7D22;&#x5F15;&#x591A;&#x4E86;&#x4E00;&#x4E2A;&#x5173;&#x952E;&#x5B57; local):</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">LOCAL</span> <span class="hljs-keyword">INDEX</span> my_index <span class="hljs-keyword">ON</span> my_table (my_index)
</code></pre>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566871246.png" alt=""></p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566871077.png" alt=""></p>
<h2 id="local-index-&#x548C;-global-index&#x533A;&#x522B;&#xFF1A;">Local index &#x548C; Global index&#x533A;&#x522B;&#xFF1A;</h2>
<p>Local index &#x7531;&#x4E8E;&#x662F;&#x6570;&#x636E;&#x4E0E;&#x7D22;&#x5F15;&#x5728;&#x540C;&#x4E00;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF0C;&#x6240;&#x4EE5;&#x8981;&#x67E5;&#x8BE2;&#x7684;&#x6570;&#x636E;&#x5728;&#x54EA;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x7684;&#x54EA;&#x4E2A;region&#x662F;&#x65E0;&#x6CD5;&#x5B9A;&#x4F4D;&#x7684;&#xFF0C;&#x53EA;&#x80FD;&#x5148;&#x627E;&#x5230;region&#x7136;&#x540E;&#x518D;&#x5229;&#x7528;&#x7D22;&#x5F15;&#x3002;</p>
<p>Global index &#x662F;&#x4E00;&#x79CD;&#x5206;&#x5E03;&#x5F0F;&#x7D22;&#x5F15;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5229;&#x7528;&#x7D22;&#x5F15;&#x5B9A;&#x4F4D;&#x670D;&#x52A1;&#x5668;&#x548C;region&#xFF0C;&#x901F;&#x5EA6;&#x66F4;&#x5FEB;&#xFF0C;&#x4F46;&#x662F;&#x7531;&#x4E8E;&#x5206;&#x5E03;&#x5F0F;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x6570;&#x636E;&#x4E00;&#x65E6;&#x51FA;&#x73B0;&#x65B0;&#x589E;&#x53D8;&#x5316;&#xFF0C;&#x5206;&#x5E03;&#x5F0F;&#x7684;&#x7D22;&#x5F15;&#x8981;&#x8FDB;&#x884C;&#x8DE8;&#x670D;&#x52A1;&#x7684;&#x540C;&#x6B65;&#x64CD;&#x4F5C;&#xFF0C;&#x5E26;&#x6765;&#x5927;&#x91CF;&#x7684;&#x901A;&#x4FE1;&#x6D88;&#x8017;&#x3002;&#x6240;&#x4EE5;&#x5728;&#x5199;&#x64CD;&#x4F5C;&#x9891;&#x7E41;&#x7684;&#x5B57;&#x6BB5;&#x4E0A;&#x4E0D;&#x9002;&#x5408;&#x5EFA;&#x7ACB;Global index&#x3002;</p>
<h2 id="432-&#x521B;&#x5EFA;&#x7D22;&#x5F15;&#x603B;&#x7ED3;">4.3.2 &#x521B;&#x5EFA;&#x7D22;&#x5F15;&#x603B;&#x7ED3;</h2>
<ol>
<li><p>&#x521B;&#x5EFA;&#x5168;&#x5C40;&#x7D22;&#x5F15;, &#x4E5F;&#x652F;&#x6301;&#x67E5;&#x8BE2;&#x5176;&#x4ED6;&#x5B57;&#x6BB5;</p>
<pre><code class="lang-sql"> <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">INDEX</span> my_index <span class="hljs-keyword">ON</span> my_table (v1) <span class="hljs-keyword">INCLUDE</span> (v2)

 <span class="hljs-keyword">SELECT</span> v2 <span class="hljs-keyword">FROM</span> my_table <span class="hljs-keyword">WHERE</span> v1 = <span class="hljs-string">&apos;foo&apos;</span>
</code></pre>
</li>
<li><p>&#x521B;&#x5EFA;&#x5C40;&#x90E8;&#x7D22;&#x5F15;</p>
<pre><code class="lang-sql"> <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">LOCAL</span> <span class="hljs-keyword">INDEX</span> my_index <span class="hljs-keyword">ON</span> my_table (v1)
</code></pre>
</li>
</ol>
<h2 id="433-&#x5220;&#x9664;&#x7D22;&#x5F15;">4.3.3 &#x5220;&#x9664;&#x7D22;&#x5F15;</h2>
<pre><code class="lang-sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">INDEX</span> my_index <span class="hljs-keyword">ON</span> my_table
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 4.2 配置 HBase 支持 Phoenix 创建二级索引">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"4.3 Phoenix 创建索引","level":"1.4.3","depth":2,"previous":{"title":"4.2 配置 HBase 支持 Phoenix 创建二级索引","level":"1.4.2","depth":2,"path":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.md","ref":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/43-chuang-jian-suo-yin.md","mtime":"2019-08-27T02:11:56.065Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-08-27T02:14:08.566Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

